package com.itqn.servlet;

import com.itqn.service.Impl.ProductServiceImpl;
import com.itqn.service.ProductService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(value = "/ProductDeleteAllServlet")
public class ProductDeleteAllServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            String key = request.getParameter("key");
            //创建业务逻辑层对象
            ProductService productService=new ProductServiceImpl();
            int result = productService.deleteAll(key);
            if (result>0){
                response.sendRedirect("/admin/product.jsp?index=1");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
